#include"Slist.h"

SLNode* nizhi(struct SLNode* head1) {
    SLNode* newhead = NULL;
    SLNode* cur = head1;
    while (cur)
    {
        struct ListNode* next = cur->next;

        cur->next = newhead;
        newhead = cur;
        cur = next;
    }
    return newhead;
}

SLNode* zhongjian(SLNode* head2)
{
    SLNode* fast = head2;
    SLNode* slow = head2;

    while (fast->next && fast) {
        fast = fast->next->next;
        slow = slow->next;
    }
    return slow;
}

bool chkPalindrome(SLNode* A) {
    // write code here
    SLNode* mid = zhongjian(A);
    SLNode* newhead = nizhi(mid);

    while (newhead && A) {
        if (newhead->data != A->data)
            return false;

        newhead = newhead->next;
        A = A->next;
    }
    return true;
}



int main()
{
	SLNode* head = NULL;
	SLPushBack(&head, 559);
	SLPushBack(&head, 526);
	SLPushBack(&head, 134);
	SLPushBack(&head, 568);
	SLPushBack(&head, 197);
	SLPushBack(&head, 532);
	//SLPrint(head);
    chkPalindrome(head);
	return 0;
}